<?php
header('content-type:text/html;charset=utf-8');

$servername = 'localhost';
$username = 'root';
$password = 'root';
$db = 'sy2002';

$conn = new mysqli($servername, $username, $password, $db);

if ($conn->connect_error) {
    die("连接失败" . $conn->connect_error);
}
$sql = 'SELECT * FROM `news2`';
$res = $conn->query($sql);
$arr=array();
while($row = mysqli_fetch_assoc($res)){
    array_push($arr,$row);
};
echo json_encode($arr);
?>
